<?php

/**
 * This is the model class for table "gl_sms".
 *
 * The followings are the available columns in table 'gl_sms':
 * @property string $sms_id
 * @property string $mobile
 * @property string $content
 * @property integer $type
 * @property integer $cap_valid
 * @property string $cap_code
 * @property integer $success
 * @property string $err_code
 * @property string $err_msg
 * @property string $create_time
 * @property integer $is_delete
 * @property string $update_time
 * @property string $expire_time
 * @property string $created_by
 * @property string $updated_by
 */
class GlSms extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return GlSms the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'gl_sms';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('mobile, create_time', 'required'),
			array('type, cap_valid, success, is_delete', 'numerical', 'integerOnly'=>true),
			array('mobile, err_msg', 'length', 'max'=>200),
			array('cap_code, err_code', 'length', 'max'=>100),
			array('created_by, updated_by', 'length', 'max'=>255),
			array('content, update_time, expire_time', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('sms_id, mobile, content, type, cap_valid, cap_code, success, err_code, err_msg, create_time, is_delete, update_time, expire_time, created_by, updated_by', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'sms_id' => 'Sms',
			'mobile' => 'Mobile',
			'content' => 'Content',
			'type' => 'Type',
			'cap_valid' => 'Cap Valid',
			'cap_code' => 'Cap Code',
			'success' => 'Success',
			'err_code' => 'Err Code',
			'err_msg' => 'Err Msg',
			'create_time' => 'Create Time',
			'is_delete' => 'Is Delete',
			'update_time' => 'Update Time',
			'expire_time' => 'Expire Time',
			'created_by' => 'Created By',
			'updated_by' => 'Updated By',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('sms_id',$this->sms_id,true);
		$criteria->compare('mobile',$this->mobile,true);
		$criteria->compare('content',$this->content,true);
		$criteria->compare('type',$this->type);
		$criteria->compare('cap_valid',$this->cap_valid);
		$criteria->compare('cap_code',$this->cap_code,true);
		$criteria->compare('success',$this->success);
		$criteria->compare('err_code',$this->err_code,true);
		$criteria->compare('err_msg',$this->err_msg,true);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('is_delete',$this->is_delete);
		$criteria->compare('update_time',$this->update_time,true);
		$criteria->compare('expire_time',$this->expire_time,true);
		$criteria->compare('created_by',$this->created_by,true);
		$criteria->compare('updated_by',$this->updated_by,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}